

#ifndef __TUYA_ERROR_H__
#define __TUYA_ERROR_H__

#include <stdint.h>
#include <stdbool.h>

#define TUYA_P2P_SUCCESS 0

#define TUYA_P2P_ERRNO_START                 1000
#define TUYA_P2P_ERRNO_STUN_START            10000
#define TUYA_P2P_ERRNO_RTP_START             120000
#define TUYA_P2P_ERR_MSG_SIZE                80
#define TUYA_P2P_STATUS_FROM_STUN_CODE(code) (code)

#define TUYA_P2P_EBUG             (TUYA_P2P_ERRNO_START + 0)  /* 1000 */
#define TUYA_P2P_EUNKNOWN         (TUYA_P2P_ERRNO_START + 1)  /* 1001 */
#define TUYA_P2P_EPENDING         (TUYA_P2P_ERRNO_START + 2)  /* 1002 */
#define TUYA_P2P_ETOOMANYCONN     (TUYA_P2P_ERRNO_START + 3)  /* 1003 */
#define TUYA_P2P_EINVAL           (TUYA_P2P_ERRNO_START + 4)  /* 1004 */
#define TUYA_P2P_ENAMETOOLONG     (TUYA_P2P_ERRNO_START + 5)  /* 1005 */
#define TUYA_P2P_ENOTFOUND        (TUYA_P2P_ERRNO_START + 6)  /* 1006 */
#define TUYA_P2P_ETOOMANY         (TUYA_P2P_ERRNO_START + 10) /* 1010 */
#define TUYA_P2P_EBUSY            (TUYA_P2P_ERRNO_START + 11) /* 1011 */
#define TUYA_P2P_ENOTSUP          (TUYA_P2P_ERRNO_START + 12) /* 1012 */
#define TUYA_P2P_EINVALIDOP       (TUYA_P2P_ERRNO_START + 13) /* 1013 */
#define TUYA_P2P_ETOOSMALL        (TUYA_P2P_ERRNO_START + 19) /* 1019 */
#define TUYA_P2P_EIGNORED         (TUYA_P2P_ERRNO_START + 20) /* 1020 */
#define TUYA_P2P_SOCKETCREATEFAIL (TUYA_P2P_ERRNO_START + 30) /* 1030 */

#define TUYA_P2P_INVALID_PARAM   (TUYA_P2P_ERRNO_START + 31) /* 1031 */
#define TUYA_P2P_MALLOC_FAILED   (TUYA_P2P_ERRNO_START + 32) /* 1032 */
#define TUYA_P2P_LOG_BUFFER_FULL (TUYA_P2P_ERRNO_START + 33) /* 1033 */

/************************************************************
 * STUN MESSAGING ERRORS
 ***********************************************************/

#define TUYA_P2P_EINSTUNMSG        (TUYA_P2P_ERRNO_STUN_START + 1)  /* 10001 */
#define TUYA_P2P_EINSTUNMSGLEN     (TUYA_P2P_ERRNO_STUN_START + 2)  /* 10002 */
#define TUYA_P2P_EINSTUNMSGTYPE    (TUYA_P2P_ERRNO_STUN_START + 3)  /* 10003 */
#define TUYA_P2P_ESTUNTIMEDOUT     (TUYA_P2P_ERRNO_STUN_START + 4)  /* 10004 */
#define TUYA_P2P_ESTUNTOOMANYATTR  (TUYA_P2P_ERRNO_STUN_START + 21) /* 10021 */
#define TUYA_P2P_ESTUNINATTRLEN    (TUYA_P2P_ERRNO_STUN_START + 22) /* 10022 */
#define TUYA_P2P_ESTUNDUPATTR      (TUYA_P2P_ERRNO_STUN_START + 23) /* 10023 */
#define TUYA_P2P_ESTUNFINGERPRINT  (TUYA_P2P_ERRNO_STUN_START + 30) /* 10030 */
#define TUYA_P2P_ESTUNMSGINTPOS    (TUYA_P2P_ERRNO_STUN_START + 31) /* 10031 */
#define TUYA_P2P_ESTUNFINGERPOS    (TUYA_P2P_ERRNO_STUN_START + 33) /* 10033 */
#define TUYA_P2P_ESTUNNOMAPPEDADDR (TUYA_P2P_ERRNO_STUN_START + 40) /* 10040 */
#define TUYA_P2P_ESTUNIPV6NOTSUPP  (TUYA_P2P_ERRNO_STUN_START + 41) /* 10041 */
#define TUYA_P2P_EINVAF            (TUYA_P2P_ERRNO_STUN_START + 42) /* 10042 */
#define TUYA_P2P_ESTUNINSERVER     (TUYA_P2P_ERRNO_STUN_START + 50) /* 10050 */

/************************************************************
 * STUN SESSION/TRANSPORT ERROR CODES
 ***********************************************************/
#define TUYA_P2P_ESTUNDESTROYED (TUYA_P2P_ERRNO_STUN_START + 60) /* 10060 */
#define TUYA_P2P_ENOICE         (TUYA_P2P_ERRNO_STUN_START + 80) /* 10080 */
#define TUYA_P2P_EICEINPROGRESS (TUYA_P2P_ERRNO_STUN_START + 81) /* 10081 */
#define TUYA_P2P_EICEFAILED     (TUYA_P2P_ERRNO_STUN_START + 82) /* 10082 */
#define TUYA_P2P_EICEMISMATCH   (TUYA_P2P_ERRNO_STUN_START + 83) /* 10083 */
#define TUYA_P2P_EICEINCOMPID   (TUYA_P2P_ERRNO_STUN_START + 86) /* 10086 */
#define TUYA_P2P_EICEINCANDID   (TUYA_P2P_ERRNO_STUN_START + 87) /* 10087 */
#define TUYA_P2P_EICEINSRCADDR  (TUYA_P2P_ERRNO_STUN_START + 88) /* 10088 */
#define TUYA_P2P_EICEMISSINGSDP (TUYA_P2P_ERRNO_STUN_START + 90) /* 10090 */
#define TUYA_P2P_EICEINCANDSDP  (TUYA_P2P_ERRNO_STUN_START + 91) /* 10091 */
#define TUYA_P2P_EICENOHOSTCAND (TUYA_P2P_ERRNO_STUN_START + 92) /* 10092 */
#define TUYA_P2P_EICENOMTIMEOUT (TUYA_P2P_ERRNO_STUN_START + 93) /* 10093 */

/************************************************************
 * TURN ERROR CODES
 ***********************************************************/
#define TUYA_P2P_ETURNINTP (TUYA_P2P_ERRNO_STUN_START + 120) /* 10120 */

#define TUYA_P2P_RTP_EINPACK (TUYA_P2P_ERRNO_RTP_START + 121) /* 120121 */
#define TUYA_P2P_RTP_EINVER  (TUYA_P2P_ERRNO_RTP_START + 122) /* 120122 */
#define TUYA_P2P_RTP_EINLEN  (TUYA_P2P_ERRNO_RTP_START + 125) /* 120125 */

extern void tuya_p2p_strerror(int32_t statcode, char *buf, size_t bufsize);

#endif
